package LeetCode.leetcode;

/**
 * 各位相加
 * @author: leiwenkang02@meituan.com
 * @date: 2018/8/27
 * @time: 14:09
 */
public class Test258各位相加 {
    public static void main(String[] args) {
        System.out.println(addDigits(3));
    }

    public static int addDigits(int num) {
        while (num >= 10) {
            int sum = 0;
            while (num != 0) {
                sum += num % 10;
                num = num / 10;
            }
            num = sum;
        }
        return num;
    }
}

